package demo2;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentArraylistTest {
    public static void main(String[] args) {
        ArrayList<StudentArraylist> stu = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            StudentArraylist s = new StudentArraylist();
            System.out.println("请输入学生姓名：");
            String name = sc.next();
            System.out.println("请输入学生年龄：");
            int age = sc.nextInt();
            s.setName(name);
            s.setAge(age);
            stu.add(s);
        }
        System.out.println(stu.size());
        for (int i = 0; i < stu.size(); i++) {
            StudentArraylist s= stu.get(i);
            System.out.println(s.getName()+" "+s.getAge());
        }
    }
}